// var new_array = arr.map(function callback(currentValue[, index[, array]]) {
//     // Return element for new_array 
//    }[, thisArg])
Array.prototype.mymap=function(callback,thisArr){
    if((typeof callback!='function')||!this){
        throw new TypeError();
    }
    var obj=Object(this);
    var len=obj.length;
    const res=[];
    for(let i=0;i<len;i++){
        if(i in obj){
            res[i]=callback.call(thisArr,obj[i],i,this);
        }
    }
    return res;
}

const arr=[1,2,3,4];
var res=arr.mymap(item=>{
    return item+1;
})
console.log(res);